def f(num):
    if num < 2:
        return False
    for i in range(2, int(num //2) + 1):
        if num % i == 0:
            return False
    return True
def c(w1, w2, w3):
    numbers = {'zero': 0, 'one': 1, 'two': 2, 'three': 3, 'four': 4, 'five': 5, 'six': 6, 'seven': 7, 'eight': 8, 'nine': 9}
    if not(w1 in numbers and w2 in numbers and w3 in numbers):
        print("wrong input")
        return False
    ns = str(numbers[w1]) + str(numbers[w2]) + str(numbers[w3])
    
    if  len(ns) != 3 and ns not in numbers:
        print("wrong input")
        return
    
    num = int(ns)
    
    lm = num
    um = num
    
    while True:
        if f(lm):
            print(lm)
            return
        if f(um):
            print(um)
            return
        lm -= 1
        um += 1
w= input("три слова: ").split()
if len(w) == 3:
    a,b,x =  w
    c(a,b,x)
else:
    print("Wrong input")
